package main

import "fmt"

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

func buildTree() *TreeNode {
	node7 := &TreeNode{Val: 7, Left: nil, Right: nil}
	node6 := &TreeNode{Val: 6, Left: nil, Right: nil}
	node5 := &TreeNode{Val: 5, Left: nil, Right: nil}
	node4 := &TreeNode{Val: 4, Left: nil, Right: nil}
	node3 := &TreeNode{Val: 3, Left: node6, Right: node7}
	node2 := &TreeNode{Val: 2, Left: node4, Right: node5}
	node1 := &TreeNode{Val: 1, Left: node2, Right: node3}
	return node1
}

func preorderTraversal(root *TreeNode) {
	if root == nil {
		return
	}
	fmt.Println(root.Val)
	preorderTraversal(root.Left)
	preorderTraversal(root.Right)
}

func main() {
	root := buildTree()
	preorderTraversal(root)
}


